package cn.bdqn.study_String;

import java.util.Random;

public class ObjectArray {

    public static void main(String[] args) {

        String str = "33";
        //Object是所有类的根类
        //任意引用数据类型的对象都可以自动类型转换成Object类型对象
        Object o = str;

        //类是对象的数据类型
        //对象是类的实例
        //User是数据类型，u是对象名
        //new User();创建User类型的对象（变量值）
        User u = new User();
        u.name = "admin";
        u.password = "123456";
        u.sex = '男';
        u.age = 20;
        u.show();

        int[] nums;
        nums = new int[4];
        Random r = new Random();
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            nums[i] = r.nextInt(10);
            System.out.println("第" + (i + 1) + "元素的值是：" + nums[i]);
            sum += nums[i];
        }
        System.out.println("和是：" + sum);

        User[] us;
        us = new User[3];
        //us[0] = new User();
        for (int i = 0; i < us.length; i++) {
            us[i] = new User();
            us[i].name = "admin"+i;
            us[i].password = "1111"+i;
            us[i].sex = '男';
            us[i].age = 22+i;
            us[i].show();
        }

    }

}
